import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Console;
import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSON;
import com.alibaba.fastjson.JSONObject;
import com.smdk.dsminio.common.CommonVariable;
import com.smdk.dsminio.utils.DateUtil;
import com.smdk.dsminio.utils.FileMD5Util;
import com.smdk.dsminio.vo.MultipartFileParam;
import org.junit.Test;

import java.io.File;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 神秘的凯
 * @version 1.0
 * @className aaa
 * @date 2020/11/25/025 19:14
 * @Description 描述
 */
public class aaa {

    @Test
    public void  aa(){
        String a="E:/SVN/hangzhouyinxiong/dsminio/data/temp/\\OSS-STORAGE-SERVICE-01\\NODEA249\\NODEB107\\微信图片_20190225181035.jpg";
        String pattern = "OSS-STORAGE-SERVICE-[0-9]*/[a-zA-Z0-9]*/[a-zA-Z0-9]*/";
        System.out.println(a.replace("\\","/").replaceAll(pattern,""));
    }

    @Test
    public void  bb(){
        Map<String,Object> paramMap;
        File file=new File("F:\\wwwback4.zip");
        MultipartFileParam multipartFileParam =new MultipartFileParam();
        multipartFileParam.setFileBaseStr(Base64.encode(file));
        multipartFileParam.setBucketId(0L);
        multipartFileParam.setChunk(0);
        multipartFileParam.setChunks(1);
        multipartFileParam.setParentFolderId(0L);
        multipartFileParam.setSize(file.length());
        multipartFileParam.setUid("ax001");
        multipartFileParam.setId("0");
        multipartFileParam.setMd5(FileMD5Util.calcMD5(file));
        multipartFileParam.setFileName(file.getName());
        paramMap= BeanUtil.beanToMap(multipartFileParam);
        //Gateway网关
        HttpRequest.post("http://w2pb2wgp7ebe6x1:9008/api-a/api/fileNodeDistribute").form(paramMap).timeout(5000).execute().body();
        //直接请求
      //  HttpRequest.post("http://w2pb2wgp7ebe6x1:9002/api/fileNodeDistribute").form(paramMap).execute().body();
    }

    @Test
    public void cc(){
        System.out.println(CommonVariable.ossLogsPath+ DateUtil.formatDateByPattern(new Date(),"yyyy-MM-dd")+".log");
    }
}
